all: os-image

run: all
	bochs

# qemu
# run:
# 	qemu-system-x86_64 -nographic $(dir)/boot_sect.bin


os-image: kernel.bin boot_sect.bin
	cat $(dir)/boot_sect.bin $(dir)/kernel.bin > $(dir)/os-image 

boot_sect.bin: 
	nasm $(dir)/boot_sect.asm -o $(dir)/boot_sect.bin

kernel.bin: kernel.o kernel_entry.o
	x86_64-elf-ld -o $(dir)/kernel.bin -Ttext 0x1000 $(dir)/kernel_entry.o  $(dir)/kernel.o --oformat binary
kernel.o: $(dir)/kernel.c
	x86_64-elf-gcc -ffreestanding -c $(dir)/kernel.c -o $(dir)/kernel.o
kernel_entry.o: $(dir)/kernel_entry.asm
	nasm $(dir)/kernel_entry.asm -f elf64 -o $(dir)/kernel_entry.o 

clean:
	rm $(dir)/*.bin $(dir)/*.o
